package com.strongdigit.ioc;

import com.strongdigit.aop.schemabased.BizMode;
import com.strongdigit.aop.schemabased.IFit;
import com.strongdigit.ioc.autowiring.AutoWiringService;
import com.strongdigit.ioc.aware.MoocApplicationContext;
import com.strongdigit.ioc.aware.MoocBeanName;
import com.strongdigit.ioc.beanannotation.BeanAnnotation;
import com.strongdigit.ioc.beanannotation.javabased.DataSourceManager;
import com.strongdigit.ioc.beanannotation.javabased.StringStore;
import com.strongdigit.ioc.beanannotation.jsr.jsrService;
import com.strongdigit.ioc.beanannotation.multibean.BeanInvoker;
import com.strongdigit.ioc.beanannotation.service.InjectionServiceImpl;
import com.strongdigit.ioc.beans.BeanScope;
import com.strongdigit.ioc.beans.Example;
import com.strongdigit.ioc.beans.InitBeanExample;
import com.strongdigit.ioc.resource.MoocResource;

import jdk.nashorn.internal.ir.IfNode;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {

    public static void main(final String[] args) throws Exception {

        //System.out.println("test");
        /*ApplicationContext context=new ClassPathXmlApplicationContext("classpath:spring-injection.xml");

        InjectionServiceImpl impl = (InjectionServiceImpl) context.getBean("injectionServiceImpl");
        impl.save("test 100");*/

/*
        ApplicationContext context1=new ClassPathXmlApplicationContext("classpath:spring-beanscope.xml");

        BeanScope bean = (BeanScope) context1.getBean("beanScope");
        bean.say();
        //ApplicationContext context2=new ClassPathXmlApplicationContext("classpath:spring-beanscope.xml");

        BeanScope bean1 = (BeanScope) context1.getBean("beanScope");
        bean1.say();*/
/*

        ClassPathXmlApplicationContext context1 = new ClassPathXmlApplicationContext("classpath:spring-beanlifecyc.xml");

        Example bean = (Example) context1.getBean("exampleBean");

*/

        // InitBeanExample bean = (InitBeanExample) context1.getBean("initBeanExample");

        // ((ClassPathXmlApplicationContext)context1).close();


       /* ClassPathXmlApplicationContext context1 = new ClassPathXmlApplicationContext("classpath:spring-aware.xml");

        MoocBeanName bean = (MoocBeanName) context1.getBean("moocBeanName");
        System.out.println("Main:"+bean.hashCode());*/

       /* ClassPathXmlApplicationContext context1 = new ClassPathXmlApplicationContext("classpath:spring-autowiring.xml");

        AutoWiringService bean = (AutoWiringService) context1.getBean("autoWiringService");
        bean.say("this is a test");*/


       /* ClassPathXmlApplicationContext context1 = new ClassPathXmlApplicationContext("classpath:spring-resource.xml");

        MoocResource bean = (MoocResource) context1.getBean("moocResource");
        bean.loadResource();*/

//        ClassPathXmlApplicationContext context1 = new ClassPathXmlApplicationContext("classpath:spring-beanannotation.xml");
//
//        BeanAnnotation bean = (BeanAnnotation) context1.getBean("bean");
//
//        //bean.say("test 123");
//        bean.testscope();
//
//        BeanAnnotation bean1 = (BeanAnnotation) context1.getBean("bean");
//        bean1.testscope();


        // ClassPathXmlApplicationContext context1 = new ClassPathXmlApplicationContext("classpath:spring-beanannotation.xml");

//        InjectionServiceImpl bean = (InjectionServiceImpl) context1.getBean("injectionServiceImpl");
//
//        bean.save("test");

        // BeanInvoker bean = (BeanInvoker) context1.getBean("beanInvoker");
        //bean.say();

//        StringStore bean = (StringStore) context1.getBean("stringstore");
//        System.out.println(bean.getClass().getName());
//        ClassPathXmlApplicationContext ctx =  (ClassPathXmlApplicationContext)bean.getCtx();
//        ctx.close();

//        DataSourceManager bean = (DataSourceManager) context1.getBean("dataSourceManager");
//        bean.say();
//
//        StringStore bean = (StringStore) context1.getBean("stringstore");
//        System.out.println(bean.hashCode());
//        StringStore bean1 = (StringStore) context1.getBean("stringstore");
//        System.out.println(bean1.hashCode());


//测试@Resouce注解
//        jsrService bean= (jsrService)context1.getBean("jsrService");
//        bean.save();
//        context1.close();
        ClassPathXmlApplicationContext context1 = new ClassPathXmlApplicationContext("classpath:spring-aop.xml");
//
//        BizMode mode = (BizMode) context1.getBean("bizMode");
//        //mode.biz();
//        mode.init("tiansx",18);

        IFit filter = (IFit) context1.getBean("bizMode");
        filter.filter();

    }


}
